package com.atguigu.day08.HomeWork.HomeWork1;

import java.util.Scanner;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/8 20:37
 * @注释
 */
public class HomeWork1Test {



    public static void main(String[] args) {
        //创建键盘输入对象,对员工信息进行记录

        HomeWork1[] h = sort();
        System.out.println("=======================员工信息一览表=========================");
        System.out.println("姓名 " + "   性别 " + "    年龄 " + "      工资 " + "     \t  电话  " + "        \t 邮箱   ");
        showInfo(h);


    }

    private static void showInfo(HomeWork1[] h) {
        for(HomeWork1 homeWork1: h){
            String info = homeWork1.toString();
            System.out.println(info);
        }
    }

    public static HomeWork1[] sort() {
        Scanner sc = new Scanner(System.in);
        HomeWork1[] hw = new HomeWork1[3];

        hw[0] = new HomeWork1();
        hw[1] = new HomeWork1();
        hw[2] = new HomeWork1();

        HomeWork1[] hw2 = new HomeWork1[3];
        boolean flag;
        int i = 0;
        do{
            System.out.println("----------第" + (i + 1) + "位员工------------");
            System.out.print("姓名: ");
            String name = sc.next();
            System.out.print("性别: ");
            char gender = sc.next().charAt(0);
            System.out.print("年龄: ");
            int age = sc.nextInt();
            System.out.print("工资: ");
            double salary = sc.nextDouble();
            System.out.print("电话: ");
            String telephone = sc.next();
            System.out.print("邮箱: ");
            String emile = sc.next();
            System.out.println("是否停止输入下一位(true/false): ");
            flag = sc.nextBoolean();

            hw[i].setName(name);
            hw[i].setGender(gender);
            hw[i].setAge(age);
            hw[i].setSalary(salary);
            hw[i].setTelephone(telephone);
            hw[i].setMailbox(emile);

            hw2[i] = hw[i];

            i++;
        }while(flag);
        sc.close();
        return hw2;
    }
}
